<? 
$db1=mysql_connect("localhost","root","root"); 
mysql_select_db('comld',$db1); 
$sql1="SELECT * FROM `report_nojailbreak`"; 
$result1=mysql_query($sql1,$db1); 
$row1=mysql_fetch_array($result1); 
var_dump($row1['logdate']); 

$db2=mysql_connect('192.168.0.185:5029','root','root'); 
mysql_select_db('comld',$db2); 
$sql2="SELECT DISTINCT whatdate FROM `comld`"; 
$result2=mysql_query($sql2,$db2); 
$row2=mysql_fetch_array($result2); 
var_dump($row2['whatdate']); 
$logdate =  mysql_query("SELECT DISTINCT whatdate FROM comld ORDER BY whatdate ASC",$db2);

while($everylogdate = mysql_fetch_array($logdate))

{
     //游戏总注册人数
    $loginPersonNum_query = mysql_query("SELECT count(DISTINCT deviceid) FROM comld where Jailbreak = '0'",$db2);

    $loginPersonNum = mysql_fetch_array($loginPersonNum_query);

    //日均游戏时间
    $totalDayTotalTime_query = mysql_query("SELECT avg(fGameTimeToday)  FROM comld where Jailbreak = '0'",$db2);
    $totalDayTotalTime = mysql_fetch_array($totalDayTotalTime_query);

     //日均金钱获得
    $totalDayGetMoney_query = mysql_query("SELECT avg(nGoldGainFromGameToday) FROM comld where Jailbreak = '0'",$db2);
    $totalDayGetMoney = mysql_fetch_array($totalDayGetMoney_query);

     $sql="REPLACE INTO report_nojailbreak (logdate,loginPersonNum,totalDayTotalTime,totalDayGetMoney) 
                  VALUES('$everylogdate[whatdate]','$loginPersonNum[0]','$totalDayTotalTime[0]','$totalDayGetMoney[0]')";
$query= @mysql_query($sql,$db1) or die(mysql_error());  
    }
?>